<?php
if (!isset($r)) $r = "../";
require_once($r."_engine/c_account.php");
require_once($r."_engine/c_resources_storage.php");
require_once($r."_header_ext.php");

if (!isset($account)) {
    $account = GetActiveAccount();
}

//include "cp__process.php";


SaveLoadViewParams($account, 
	$curr_page, $total_monitors, $total_pages,
	$sort_field, $sort_order
);

function process_sort_hdr($f, $text)
{
	global $r, $sort_field, $sort_order;
	
	if ($f == $sort_field)
		$so2 = ($sort_order == "asc") ? "desc" : "asc";
	else
		$so2 = "asc";
	
	$s = '<a style="color:#ffffff;" href="?sort_field='.$f.'&sort_order='.$so2.'">'.$text.'</a>';

	$it = ($so2 == "asc") ? "down" : "up";
	if ($f == $sort_field) $s .= '&nbsp;<img src="'.$r.'images/srt_'.$it.'.gif" width=5 xheight=6 border=0>';

	return $s;
}
?>


<table class=dash>
  <thead>
  <tr>
    <th class=dash-col1 scope=col><div class=dash-div-col1 style="text-indent: 26;">
        <?php echo process_sort_hdr("title",                "Name");     ?></div></th>
    <th class=dash-col2 scope=col><div class=dash-div-col2>
        <?php echo process_sort_hdr("category_name",        "Group");    ?></div></th>
    <th class=dash-col3 scope=col><div class=dash-div-col3>
        <?php echo process_sort_hdr("status",               "Status");   ?></div></th>
    <th class=dash-col4 scope=col><div class=dash-div-col4>
        <?php echo process_sort_hdr("rs_download_dt",       "Monitored");?></div></th>
    <th class=dash-col5 scope=col><div class=dash-div-col5>
        <?php echo process_sort_hdr("rs_resource_status",   "Result");   ?></div></th>
  </tr>
  </thead>
  <tbody></tbody>
</table>


<!--div id=divNewMon></div-->
<div id=divMonitors>
<?php
$ms = $account->GetMonitors($curr_page, $sort_field, $sort_order);
$ms_id = "";
$mon_cntr = 1;

foreach ($ms as $m)
{
    if ($ms_id != "") $ms_id .= ",";
    $ms_id .= $m->id;
    
    $do_expand_monitor = ($m->id <= 0/* || $m->id == 218 TODO: remove */);

    include "cp__mon.php";
}
?>


<input type="hidden" id="cp_ids" value="<?=$ms_id?>">

</div>

